package com.example.klaraservice.controller;

import com.example.klaraservice.pojo.Category;
import com.example.klaraservice.service.CategoryService;
import com.example.klaraservice.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : Glacialerisa
 * @date : 2023/6/5 14:24
 * @desc :
 */
@Api(tags = "类型")
@RestController
@RequestMapping("/api/category")
public class CategoryController {
    @Resource
    private CategoryService categoryService;
    @ApiOperation("获取所有类型")
    @GetMapping("/getCategory")
    public R getCategory(){
        List<Category> category = categoryService.selectAllCategory();
        if (category!=null){
            return R.ok().data("category", category);
        }
        return R.error();
    }
}
